package com.reverie.generate;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;

import java.util.Collections;

public class AppEntityGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/mh", "root", "root")
                .globalConfig(builder -> {
                    builder.author("Rui.Zhou") // 设置作者
                            .outputDir("D:/workspace/reverie-service/src/main/java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com") // 设置父包名
                            .moduleName("reverie") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapper, "D:/workspace/reverie-service/src/main/java/com/reverie/mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addTablePrefix("mh_","t_").addInclude("mh_attribute","mh_cart","mh_category","mh_collect_goods","mh_coupon","mh_coupon_log",
                            "mh_goods","mh_goods_attr","mh_goods_gallery","mh_order_info","mh_order_goods","mh_region","mh_users","t_good_discount");
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().enableChainModel().enableLombok().enableFileOverride()
                            .enableRemoveIsPrefix();
                })
                .strategyConfig(builder -> {
                    builder.controllerBuilder()
                            .formatFileName("%sController").enableRestStyle();
                })
//                .templateEngine(new TemplateConfig.Builder()
//                        .disable(TemplateType.ENTITY)) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
